import { createRouter, createWebHistory } from 'vue-router'


const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'layout',
      component: () => import('@/views/layout/LayoutView.vue'),
      // 路由重定向
      redirect: '/home',
      children: [
        {
          // 首页
          path: 'home',
          name: 'home',
          component: () => import('@/views/home/HomeView.vue')
        },
        {
          // 购物车
          path: 'cart',
          name: 'cart',
          component: () => import('@/views/cart/CartView.vue')
        },
        {
          // 订单
          path: 'order',
          name: 'order',
          component: () => import('@/views/order/OrderView.vue')
        },
        {
          // 用户
          path: 'my',
          name: 'my',
          component: () => import('@/views/my/MyView.vue')

        }

      ]
    },
    {
      // 地址详情
      path: '/ress',
      name: 'ress',
      component: () => import('@/views/my/AddressView.vue')
    },
    {
      // 添加地址
      path: '/address',
      name: 'address',
      component: () => import('@/views/my/CreateAddressView.vue')
    },
    {
      // 商品
      path: '/shop/:id',
      name: 'shop',
      component: () => import('@/views/shop/ShopView.vue'),
      props(res) {
        // 打印内容
        // console.log(res);
        return res.params
      }
    },
    {
      // 提交订单
      path: '/orderConfirmation',
      name: 'orderConfirmation',
      component: () => import('@/views/order/OrderConfirmationView.vue')
    }
  ]

})



export default router
